Syntax of numerical constants

The syntax of the written representations for numbers is described formally in section~#numbersyntax#651>.

A number may be written in binary, octal, decimal, or hexadecimal by the use of a radix prefix. The radix prefixes are <#652#> #b<#652#><#653#>b<#653#> (binary), <#654#>#o<#654#><#655#>o<#655#> (octal), <#656#> #d<#656#><#657#>d<#657#> (decimal), and <#658#>#x<#658#><#659#>x<#659#> (hexadecimal). With no radix prefix, a number is assumed to be expressed in decimal.

A numerical constant may be specified to be either <#2350#>exact<#2350#> or <#2351#>inexact<#2351#> by a prefix. The prefixes are <#662#>#e<#662#><#663#>e<#663#> for <#2352#>exact<#2352#>, and <#665#>#i<#665#><#666#>i<#666#> for <#2353#>inexact<#2353#>. An exactness prefix may appear before or after any radix prefix that is used. If the written representation of a number has no exactness prefix, the constant may be either <#2354#>inexact<#2354#> or <#2355#>exact<#2355#>. It is <#2356#>inexact<#2356#> if it contains a decimal point, an exponent, or a ``'' character in the place of a digit, otherwise it is <#2357#>exact<#2357#>.

In systems with <#2358#>inexact<#2358#> numbers of varying precisions it may be useful to specify the precision of a constant. For this purpose, numerical constants may be written with an exponent marker that indicates the desired precision of the <#2359#>inexact<#2359#> representation. The letters <#674#>s<#674#>, <#675#>f<#675#>, <#676#>d<#676#>, and <#677#>l<#677#> specify the use of <#678#>short<#678#>, <#679#>single<#679#>, <#680#>double<#680#>, and <#681#>long<#681#> precision, respectively. (When fewer than four internal <#2360#>inexact<#2360#> representations exist, the four size specifications are mapped onto those available. For example, an implementation with two internal representations may map short and single together and long and double together.) In addition, the exponent marker <#683#>e<#683#> specifies the default precision for the implementation. The default precision has at least as much precision as <#684#>double<#684#>, but implementations may wish to allow this default to be set by the user.


#scheme685#